﻿using System;
using System.Collections.Generic;
using System.Linq;

using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Text;

namespace CoachingOrganizer.iOS
{
    public class Application
    {
        // This is the main entry point of the application.
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            // if you want to use a different Application Delegate class from "AppDelegate"
            // you can specify it here.
            UIApplication.Main(args, null, "AppDelegate");
        }

        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception currentException = e.ExceptionObject as Exception;
            StringBuilder messageBuilder = new StringBuilder("Error:" + Environment.NewLine);
            while (currentException != null)
            {
                messageBuilder.AppendFormat("{0} at {1}{2}-------------------{2}{2}", currentException.Message, currentException.StackTrace, Environment.NewLine);
                currentException = currentException.InnerException;
            }
            Console.WriteLine(messageBuilder.ToString());
        }
    }
}